import request from '@/utils/request'
// 注册的api
export const useRegist = (username, password, repassword) => {
  return request.post('/api/reg', {
    username,
    password,
    repassword
  })
}

// 登录的api
export const useLogin = (username, password) => {
  return request.post('/api/login', {
    username,
    password
  })
}

// 获取用户信息的api
export const getUserIfo = () => {
  return request.get('/my/userinfo')
}

// 提交更新用户信息
export const userUpdateInfoService = ({ id, nickname, email }) =>
  request.put('/my/userinfo', { id, nickname, email })

// 更新密码 
export const userUpdatePassService = ({ old_pwd, new_pwd, re_pwd }) =>
  request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })

// 用户上传图片
export const userUploadAvatarService = (avatar) => request.patch('/my/update/avatar', { avatar })